#include "./BSP/IIC/myiic.h"

I2C_HandleTypeDef hiic2;
void MyIIC_init(void)
{
    hiic2.Instance = I2C2;
    hiic2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
    hiic2.Init.ClockSpeed =  100000;
    hiic2.Init.DutyCycle =I2C_DUTYCYCLE_2;
    hiic2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
    hiic2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
    hiic2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
    hiic2.Init.OwnAddress1 = 0x00;
    hiic2.Init.OwnAddress2 = 0x00;

    HAL_I2C_Init(&hiic2);

}

void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c)
{
    if (hi2c->Instance == I2C2)
    {
     GPIO_InitTypeDef gpio_init_struct;
    __HAL_RCC_I2C2_CLK_ENABLE();
    __HAL_RCC_GPIOB_CLK_ENABLE();   

    gpio_init_struct.Mode = GPIO_MODE_AF_OD;
    gpio_init_struct.Pin = GPIO_PIN_10 | GPIO_PIN_11; // PB10, PB11
    gpio_init_struct.Pull = GPIO_PULLUP;
    gpio_init_struct.Speed = GPIO_SPEED_FREQ_HIGH;

    HAL_GPIO_Init(GPIOB, &gpio_init_struct);
        /* code */
    }
    
 
}
